package DiceGame;

import java.util.Scanner;

import tjut.db.DBDriverFactory;


public class Player {
	
	
	DiceCode dc=new DiceCode();
	//局数
	int z=0;
	//初始化
	
	public void Dice0(){
		//可以循环玩游戏,定义局数
		while(true){
		z++;
		dc.CompareSum(Dice2());
		System.out.println("输入任意数继续：(退出输入-1)");
		Scanner input =new Scanner(System.in);
		int x=input.nextInt();
		if(x==-1){
			break;
		  }
		}
	}
	
	
	//输入玩家信息
	public int[] Dice2() {
		
		Scanner input=new Scanner(System.in);
		dc.input();
		int[] arr=new int[dc.getNum()];
		for(int j=0;j<dc.getNum();j++){
			System.out.println("输入第"+(j+1)+"个玩家的ID");
		    int id=input.nextInt();
			System.out.println("输入第"+(j+1)+"个玩家的姓名");
			String name=input.next();
			System.out.println("输入第"+(j+1)+"个玩家的性别");
			String sex=input.next();
			
	    	arr[j]=dc.DianComb();
	   
	    	//插入信息到数据库
			String strSQL = "insert into DICEPLAYER (PLAYER_ID ,PLAYER_NAME,PLAYER_SEX,PLAYER_ROUND,PLAYER_GRADE,PLAYER_TIME) values(?,?,?,?,?,sysdate)";
			int i =  DBDriverFactory.getDBDriverInstance().update(strSQL,new Object[]{id,name,sex,z,arr[j]});
			System.out.println(i>0?"插入成功":"插入失败");
		}
		return arr;
		
	}
	
}
